﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="StudyTreatmentService.cs" company="ELEN 7045 GROUP II">
//    Contributed by E.Vosloo
// </copyright>
// <summary>
//   Study Treatment Domain Service
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Domain.StudyDefinition.Services
{
    #region

    using System;
    using System.Collections.Generic;
    using System.Linq;

    using Domain.StudyDefinition.Contracts.DomainServices;
    using Domain.StudyDefinition.Contracts.Repositories.Studies;
    using Domain.StudyDefinition.Entities;

    #endregion

    /// <summary>
    /// Study Treatment Domain Service
    /// </summary>
    public class StudyTreatmentService : IStudyTreatmentService
    {
        #region Constants and Fields

        /// <summary>
        /// The study repository instance.
        /// </summary>
        private readonly IStudyRepository studyRepositoryInstance;

        #endregion

        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="StudyTreatmentService"/> class.
        /// </summary>
        /// <param name="studyRepository">
        /// The study repository.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// </exception>
        public StudyTreatmentService(IStudyRepository studyRepository)
        {
            if (studyRepository == null)
            {
                throw new ArgumentNullException("studyRepository");
            }

            this.studyRepositoryInstance = studyRepository;
        }

        #endregion

        #region Implemented Interfaces

        #region IStudyTreatmentService

        /// <summary>
        /// The get all studies without treatments.
        /// </summary>
        /// <returns>
        /// </returns>
        public List<Study> GetAllStudiesWithoutTreatments()
        {
            return this.studyRepositoryInstance.Get(s => s.Treatments == null).ToList();
        }

        #endregion

        #endregion
    }
}